﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Web
{
    /// <summary>
    /// 启用接口响应结果缓存
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
    public class CachedAttribute : Attribute
    {
        /// <summary>
        /// 启用接口响应结果缓存
        /// </summary>
        /// <param name="seconds">缓存时间，单位秒</param>
        public CachedAttribute(int seconds)
        {
            this.Duration = TimeSpan.FromSeconds(seconds <= 0 ? 180 : seconds);
        }
        /// <summary>
        /// 缓存时间
        /// </summary>
        public TimeSpan Duration { get; set; }
    }
}
